function trim(val)
{
	 return val.replace(/(^\s*)|(\s*$)/g, "");  
}

function checkSub(){
	
	if(document.getElementById('consignee').value==''){
		alert('收货人姓名不能为空');
		document.getElementById('consignee').focus();
		return false;
	}
	

	var email = document.getElementById('email').value;
	  var chemEmails=/^([a-z0-9]*[-_.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})?$/i;
	
	  if(null == email || email == "")
	  {
	  	alert("邮箱不能为空!");
	  	document.getElementById("email").focus();
	  	return false;
	  }else if (!chemEmails.test(email)){
			alert("Email的格式不正确");
			document.getElementById("email").focus();
			return false;
	  }
	 var area_attr = document.getElementById('area_attr').value;
		if(document.getElementById('province').value != ''){
		 area_attr = '';
		area_attr += document.getElementById('province').value+'|';
		if(document.getElementById('eparchy_code').value!=''){
			area_attr += document.getElementById('eparchy_code').value+'|';
			if(document.getElementById('city_code').value!=''){
				area_attr += document.getElementById('city_code').value+'|';
			}
		  }
		 }
		if(area_attr == ''){
				alert('请选择您所在的地区！');
				return false;
			}
		document.getElementById('area_attr').value = area_attr;
	var address = document.getElementById("address").value;
	if(address == ""){
		alert("请输入您的详细地址");
		return false;
	}
		var post_code=document.getElementById("post_code").value;
		if(post_code==""){
			alert("请输入邮编");
			return false;
		}
		if(post_code!=""){
			if(post_code.length!=6){
		  		alert("请输入6位数字邮政编码");
		  		   document.getElementById('post_code').focus();
				   return false;
			}
		}

		var tel = document.getElementById('tel').value;
		var myreg2 =/^((0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/;
   		if(tel!=""&&!myreg2.exec(tel)){
	        	alert('请输入有效的电话号码！');
			    document.getElementById('tel').focus();
			    return false;
	       }
		
	var cellphone = document.getElementById("cellphone");
	var myreg1=/^[1][\d]{10}$/;
	
	 if(trim(cellphone.value)==''){
	      alert('请输入手机号码！');
		  document.getElementById('cellphone').focus();
	      return false; 
	  } else if(!myreg1.test(trim(cellphone.value))){
	      alert('请输入有效的手机号码！');
		  document.getElementById('cellphone').focus();
	      return false;
	  }  
   
	var addr_id=document.getElementById('addr_id').value;
	var _addr_id = document.getElementById('_addr_id').value;
	if(addr_id!=null||addr_id!=""){
		if(addr_id!=""&&addr_id!=null){
			document.addaddressForm.bpm_id.value="2575";
		}else{
			document.addaddressForm.bpm_id.value="1221";
		}
		document.addaddressForm.submit();
	}else{
		document.addaddressForm.submit();
		
	}
	return false;
}

function search(){
	document.addaddressForm.submit();
}
function ChangeOrg(){
	document.getElementById("org1").style.display = "none";
	document.getElementById("org2").style.display = "";
}